import http, {HttpOptions} from "../http"


// 响应接口
export interface GetManageRoleListRes {
    code: number;
    msg: string;
    data: {
        total: number;
        size: number;
        current: number;
        records: {
            id: number;
            perId: {
                id: number;
                name: string;
                path: string;
                mod: string;
                description: string;
                user: string;
                status: number;
            }[];
            routerId: {
                id: number;
                updateBy: string;
                status: number;
                name: string;
                url: string;
                pagePath: string;
            }[];
            roleDescription: string;
            updateBy: string;
            status: string;
            name: string;
        }[];
    };
    timestamp: number;
    now: string;
}

/**
 * 管理页面-获取角色列表
 * @param {string} page
 * @param {string} size
 * @returns
 */
export function getManageRoleList(page: number, size: number): Promise<GetManageRoleListRes> {
    const config:HttpOptions  = {
        msg: false,
        token: true,
        load: false,
    }
    return http.get(`/role/manage?page=${page}&size=${size}`, config);
}


// 响应接口
export interface GetSelectRoleListRes {
    code: number;
    msg: string;
    data: {
        id: number;
        perId: {
            id: number;
            name: string;
            path: string;
            mod: string;
            description: string;
            user: string;
            status: number;
        }[];
        routerId: {
            id: number;
            updateBy: string;
            status: number;
            name: string;
            url: string;
            pagePath: string;
        }[];
        roleDescription: string;
        updateBy: string;
        status: string;
        name: string;
    }[];
    timestamp: number;
    now: string;
}

/**
 * 管理页面-获取角色选择列表
 * @returns
 */
export function getSelectRoleList(): Promise<GetSelectRoleListRes> {
    const config:HttpOptions  = {
        msg: false,
        token: true,
        load: false,
    }
    return http.get(`/role/manage/list`, config);
}